<include file="public@header"/>
</head>
<body>
<div class="layui-fluid">
    <form method="post" class="layui-form js-ajax-form margin-top-20" action="{:url('link/editPost')}">
        <div class="layui-card">
            <div class="layui-card-header">{:lang('ADMIN_LINK_EDIT')}</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('LINK_NAME')}</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="input-link_name" name="name" value="{$link.name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('CATEGORY')}</label>
                    <div class="layui-input-block">
                        <select class="layui-input" name="cat_id" id="more-template-select">
                            {$catOptions}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('LINK_URL')}</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" id="input-link_url" name="url" value="{$link.url}">
                    </div>
                </div>

                <if condition="$link['type'] eq 2">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('UPLOAD_IMAGE')}</label>
                        <div class="layui-input-block">
                            <div class="upload-image">
                                <input type="hidden" name="image" id="thumbnail"
                                       value="{$link.image|default=''}">
                                <a href="javascript:uploadOneImage('{:lang('UPLOAD_IMAGE')}','#thumbnail');">
                                    <if condition="empty($link.image)">
                                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                             id="thumbnail-preview"
                                             width="135"/>
                                        <else/>
                                        <img src="{:cmf_get_image_preview_url($link.image)}"
                                             id="thumbnail-preview"
                                             width="135"/>
                                    </if>
                                </a>
                                <input type="button" class="layui-btn layui-btn-danger layui-btn-sm" onclick="$('#thumbnail-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumbnail').val('');return false;" value="{:lang('CANCEL_PICTURE')}">
                            </div>
                        </div>
                    </div>
                </if>

                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('LINK_TARGET')}</label>
                    <div class="layui-input-block">
                        <select class="layui-input" name="target" id="input-target">
                            <foreach name="targets" item="vo">
                                <php>$link_target_selected=$link['target']==$key?"selected='selected'":"";</php>
                                <option value="{$key}" {$link_target_selected}>{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <!-- <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('DESCRIPTION')}</label>
                    <div class="layui-input-block">
                        <textarea class="layui-input" name="description">{$link.description}</textarea>
                    </div>
                </div> -->
                <!-- 排序号 -->
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('SORT')}</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" name="list_order" value="{$link.list_order}">
                    </div>
                </div>
                <!-- 属性 -->
                <div class="layui-form-item">
                    <php>
                        $status = ($link['status'] == 0) ? "checked" : "";
                    </php>
                    <label class="layui-form-label">{:lang('ATTRIBUTE')}</label>
                    <div class="layui-input-block">
                        <input type="checkbox" id="status" name="status" value="0" title="{:lang('IS_HIDE')}" {$status}>
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="hidden" name="id" value="{$link.id}">
                        <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'admin/Link/editPost')">
                            <button type="submit" class="layui-btn layui-btn-normal js-ajax-submit">{:lang('SAVE')}</button>
                        </if>
                        <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<include file="public@footer"/>
